package com.hanoi.wiki.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.hanoi.wiki.model.json.UserStatisticJson;

@Entity
@Table(name="USER_STATISTIC")
public class UserStatistic implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public UserStatistic() {
		
	}
	
	public UserStatistic(UserStatisticJson json) {
		this.recentPlace 	= json.getRecentPlace();
		this.detail 		= json.getDetail();
		this.date			= json.getDate();
		this.status			= json.getStatus();
	}
	
	@Id
	@Column(name="ID")
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Integer id;	
	
	@Column(name="RECENT_PLACE", length = 2000, nullable = false)
	private String recentPlace;
	
	@Column(name="DETAIL", length = 2000)
	private String detail;
	
	@Column(name="STATUS")
	private Integer status;
	
	@Column(name="DATE")
	private Date date;
	
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	private User user;	
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public String getRecentPlace() {
		return recentPlace;
	}
	public void setRecentPlace(String recentPlace) {
		this.recentPlace = recentPlace;
	}
	public String getDetail() {
		return detail;
	}
	public void setDetail(String detail) {
		this.detail = detail;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
}
